<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<input type="checkbox" >
<button id="btn">按钮</button>
<script>
var input = document.querySelector("input");
input.onchange = function (){
    console.log(input.checked);
}

btn.onclick = function (){
    input.checked = true;
}
input.style.backgroundColor = "red";
</script>
</body>
</html>